import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
// import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
// 改为中文
// Vue.use(ElementUI, { zhLocale })


import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control



// 解决浏览器的警告
import 'default-passive-events'

// 自定义组件的导入
import * as directives from '@/directives'
// 遍历所有的导出指令对象，完成自定义全局注册
Object.keys(directives).forEach(key => {
  //注册自定义指令
  Vue.directive(key, directives[key])
})
/**
 * 导入注册全局过滤器
 */
// import * as filters from '@/filters'
// // 遍历所有导出的函数，并完成全局注册
// Object.keys(filters).forEach(key => {
//   Vue.filter(key, filters[key])
// })

// 用for··in··来遍历,暂时没能透彻理解Object.key和for··in之间的效率等区别  时2021-8-4日
import * as filters from "@/filters"
for (let key in filters) {
  Vue.filter(key, filters[key])
}

// 似乎可以解决devtools无法显示的问题
Vue.config.devtools = true
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// // 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = true

// 注册headTool为全局组件
import components from '@/components'
Vue.use(components)

// 导入mixin注册成全局的混入函数
import { rolePoints } from '@/mixins'
Vue.mixin(rolePoints)

// 导入打印所依赖的包
import Print from 'vue-print-nb'
// Global instruction
Vue.use(Print)


// Vue-I18n国际化导入
import { i18n } from '@/i18n'

// 注册element-ui语言，并关联i18n
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

new Vue({
  el: '#app',
  i18n,
  router,
  store,
  render: h => h(App)
})
